<?php

namespace Apps\AppApi\Method\Question;
use Apps\AppApi\Method\BaseMethod;
use Apps\Common\Models\QuestionTag;


/**
 * 问题分类标签列表
 * @package Apps\AppApi\Method\TagList
 */
class TagList extends BaseMethod
{
    /**
     * @var \Apps\Common\Models\QuestionTag array
     */
    private $tags = [];

    public function run()
    {
        $this->tags = QuestionTag::query()
            ->columns([
                'tag_id id',
                'tag_title title'
            ])
            ->where('tag_state = 1')
            ->orderBy('tag_order DESC, tag_id ASC')
            ->execute()->toArray();

        $this->tags = $this->tags ? $this->tags : [];
        $this->setResult($this->tags);
    }

}